<template>
	<view>
		<view class="lineGray"></view>
		<view>
			<view class="line padding" @click="creat()">
				<image class="icon-mid" mode="aspectFit" src="../../static/find.png"></image>
				<view class="column-no bigEmpty padding">
					<text class="textblack24 bold">发布AI创作</text>
					<text class="textLightBlack16 margin-top-0">分享你的画作和指令</text>
				</view>
				<image class="icon-small" src="../../static/arrow.png"></image>
			</view>
			<view class="line padding" @click="creatPost()">
				<image class="icon-mid" mode="aspectFit" src="../../static/find1.png"></image>
				<view class="column-no bigEmpty padding">
					<text class="textblack24 bold">发布帖子</text>
					<text class="textLightBlack16 margin-top-0">分享你的AI调教经验和趣事</text>
				</view>
				<image class="icon-small" src="../../static/arrow.png"></image>
			</view>
			<view class="line padding" @click="createGroup">
				<image class="icon-mid" mode="aspectFit" src="../../static/find2.png"></image>
				<view class="column-no bigEmpty padding">
					<text class="textblack24 bold">发布合集</text>
					<text class="textLightBlack16 margin-top-0">分享你的创作主题合集</text>
				</view>
				<image class="icon-small" src="../../static/arrow.png"></image>
			</view>
			<view class="centerGroup dialogBg" v-show="showDialog">
				<view class=" dialog-bottom-full-width padding">
					<view class="line textBlack18">
						<view class="bigEmpty marginLeft">新建合集</view>
						<view class="centerGroup marginRight textblack14" @click="canleDialog">X</view>
					</view>
					<view class="line marginTop marginLeft marginRight">
						<input class="inputContent1 bigEmpty" v-model="name" maxlength="300" placeholder="输入合集名称" />
					</view>
					<view class="inputContent marginTop marginLeft marginRight">
						<textarea v-model="content" maxlength="300" placeholder="分享合集背后的故事(选填)" />
						<view class="rightLabel">
							<text> {{content.length}}/300 |</text> <text>清除</text>
						</view>
					</view>
					<view class="centerGroup marginTop">
						<view class="centerGroup ok marginLeft textwhite14" @click="okDialog">确认</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '/common/request.js';
	export default {
		data() {
			return {
				showDialog: false,
				content: "",
				name: "",
			}
		},
		onShareAppMessage(res) {
			return {
				title: '设辑-产品设计智能生成AI',
				path: '/pages/HomePage/HomePage',
				imageUrl: '/static/black-logo.png'
			}
		},
		// 自定义页面的分享到朋友圈
		onShareTimeline(res) {
			return {
				title: '设辑-产品设计智能生成AI',
				path: '/pages/HomePage/HomePage',
				imageUrl: '/static/black-logo.png'
			}
		},
		methods: {
			okDialog() {
				const that = this;
				const url = getApp().globalData.apiUrl + "/api/v1/pictureCollection "
				request(url, "POST", {
						name: this.name,
						content: this.content,
						status: 1,
						label: 1,
						image: "http://47.122.46.76:8080/v1/image/homelogo.png",
						formatImages: [],
						type: 4,
						visible: 1,
					}, uni.getStorageSync("token"))
					.then(function(res) {
						uni.showToast({
							title: "合集创建成功"
						})
						console.log('返回正确回调', res)
					}, function(err) {
						console.log('返回错误回调', err)
					})
				this.showDialog = false;
				uni.showTabBar()
			},
			canleDialog() {
				this.showDialog = false;
				uni.showTabBar()
			},
			creat() {
				uni.navigateTo({
					url: "/pages/MyPhoto/MyPhoto?openType=3"
				})
			},
			creatPost() {
				uni.navigateTo({
					url: "/pages/PublishPicture/PublishPost"
				})
			},
			createGroup() {
				uni.hideTabBar()
				this.showDialog = true
			}
		}
	}
</script>

<style>
	@import "../../common/uni.css";
</style>